<template>
  <div class="internal">
    <navbar :text="$route.params.text"></navbar>
    <div class="searchMain">
      <div class="searchInfo">
        <div class="searchImg">
          <img
            src="https://cdn7.axureshop.com/demo/1763441/images/%E5%B7%B2%E6%9C%89%E5%B0%B1%E8%AF%8A%E5%8D%A1/u1422.png"
            alt=""
          />
          <span>查询信息</span>
        </div>
        <img
          src="	https://cdn7.axureshop.com/demo/1763441/images/%E6%97%A0%E5%B0%B1%E8%AF%8A%E5%8D%A1/u1275.png"
          alt=""
        />
        <div class="bindImg">
          <img
            src="https://cdn7.axureshop.com/demo/1763441/images/%E6%97%A0%E5%B0%B1%E8%AF%8A%E5%8D%A1/u1272.svg"
            alt=""
          />
          <span>绑定就诊卡</span>
        </div>
      </div>
      <div class="searchText">
        <div class="fillName">
          <span>真实姓名<b>*</b></span>
          <input
            type="text"
            required
            placeholder="请填写您的真实姓名"
            v-model="name"
          />
        </div>
        <div class="fillIDcard">
          <span>身份证号<b>*</b></span>
          <input
            type="text"
            required
            placeholder="请填写您的身份证号"
            v-model="card"
          />
        </div>
        <div class="fillPhone">
          <span>联系电话<b>*</b></span>
          <input
            type="tel"
            required
            placeholder="请填写您的联系电话"
            v-model="tel"
            maxlength="11"
          />
        </div>
      </div>
      <div class="search">
        <van-button
          type="primary"
          size="large"
          color="#2ec7c9"
          @click.prevent="searchAciton"
          >查询</van-button
        >
      </div>
    </div>
  </div>
</template>

<script>
import navbar from "../../../components/navbar.vue";
import { getCardApi } from "../../../api/patient";
import { Button, Toast } from "vant";
export default {
  components: {
    navbar,
    [Button.name]: Button,
  },
  data() {
    return {
      name: "张三",
      card: "463474200408156471",
      tel: "19949174643",
    };
  },
  methods: {
    async searchAciton() {
      if (this.name == "" || this.card == "" || this.tel == "") {
        Toast("必填信息不可为空");
        return;
      }
      try {
        const { data } = await getCardApi({
          name: this.name,
          idcard: this.card,
          tel: this.tel,
        });
        this.$router.push({
          name: "BindMedicalCard",
          params: { text: "绑定就诊卡", data: data.data[0] },
        });
      } catch (error) {
        Toast("查无此就诊卡信息");
      }
    },
  },
};
</script>

<style lang="scss" scoped>
@function vw($px) {
  @return ($px/375) * 100vw;
}

* {
  margin: 0;
  padding: 0;
}
.searchMain {
  width: 100%;
  height: 100%;
  position: absolute;
  top: vw(55);
  z-index: 2;
  .searchInfo {
    width: 100%;
    height: vw(60);
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
    div {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      img {
        width: vw(20);
        height: vw(20);
        margin-bottom: vw(5);
      }
      span {
        font-size: vw(12);
        color: #2ec7c9;
      }
    }
    .bindImg {
      span {
        color: #333;
      }
    }
  }
  .searchText {
    margin-top: vw(12);
    padding-left: vw(20);
    display: flex;
    background: #fff;
    flex-direction: column;
    height: auto;
    div {
      height: vw(38);
      width: calc(100% - vw(20));
      display: flex;
      align-items: center;
      font-size: vw(14);
      border-bottom: vw(1) solid #cccccc69;

      span {
        width: vw(100);
        b {
          color: red;
        }
      }

      input {
        border: none;
        flex: 1;
      }
      input::placeholder {
        font-size: vw(13);
        color: #ccc;
      }
    }
  }
  .search {
    width: calc(100% - vw(70));
    height: vw(46);
    position: fixed;
    bottom: 0;
    padding: vw(5) vw(35);
    background: #fff;
    .van-button--large {
      height: vw(44);
    }
  }
}
</style>
